
#pragma once

using namespace System::Collections::Generic;
using namespace NUnit::Framework;

#include <ttg/services.h>

using namespace ttg::services;

namespace RuntimeLowTests
{
	namespace services
	{
		[TestFixture]
		public ref class StartStopTests
		{
			public:
				[Test]
				void DefaultStartStop()
				{
					try
					{
						ServiceBase::getRef()->start();
						ServiceBase::getRef()->stop();
					}
					catch (ttg::Error &err)
					{ Assert::Fail(gcnew System::String(err.toString())); }
				}

				void CustomStartStop(const char *services)
				{
					try
					{
						ServiceBase::getRef()->start(services);
						ServiceBase::getRef()->stop();
					}
					catch (ttg::Error &err)
					{ Assert::Fail(gcnew System::String(err.toString())); }
				}

				[Test]
				void StartStop_Logger()
				{ CustomStartStop("Logger"); }

				[Test]
				void StartStop_SettingsKeeper()
				{ CustomStartStop("SettingsKeeper"); }

				[Test]
				void StartStop_DllLoader()
				{ CustomStartStop("DllLoader"); }

				[Test]
				void StartStop_Timer()
				{ CustomStartStop("Timer"); }

				[Test]
				void StartStop_PublisherBase()
				{ CustomStartStop("PublisherBase"); }

				[Test]
				void StartStop_TaskScheduler()
				{ CustomStartStop("TaskScheduler"); }

				[Test]
				void StartStop_UtilManager()
				{ CustomStartStop("UtilManager"); }

				[Test]
				void UnknownService()
				{
					try
					{
						ServiceBase::getRef()->start("WTF");
						ServiceBase::getRef()->stop();
						Assert::Fail("Service \"WTF\" was sucessfully started. WTF?");
					}
					catch (ttg::Error &)
					{ /*nothing*/ }
				}
		};
	}
}
